package com.example.administrator.recycler_test;

import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private List<Photo> photoList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        for( int i = 0 ; i < 4 ; i++ ) {
            Photo photo = new Photo(R.drawable.image_test, "图：" +i );
            photoList.add(photo);
        }
        Photo photo1 = new Photo(R.drawable.a_9, "怪：" );
        photoList.add(photo1);


        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv_test);

        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);

        PhotoAdapter adapter = new PhotoAdapter(photoList);

        recyclerView.setAdapter(adapter);

    }
}
